<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.js"></script>
</head>

<body>
    <pre>
        props是一个单向数据流
        他只可以用来接收数据，不可以直接修改传递过来的数据
    </pre>
    <div class="box">
        <div :style="{fontSize: fontSize + 'px'}">{{name}}</div>
        <wzp @enlarge-text='handle' @event="handle1($event)"></wzp>
        <div>{{ msg }}</div>
    </div>
    <script>
        Vue.component('wzp', {
            data: function () {
                return {
                    name: '子组件内容',
                    msg: ''
                }
            },
            template: `
            <div>
                <p> {{ name }} </p>   
                <button @click='$emit("enlarge-text")'>字体变大</button> 
                <input type="text" @change='$emit("event",msg)' v-model='msg'>
                <div>{{ msg }}</div>
            </div>
            `
        })
        var vm = new Vue({
            el: '.box',
            data: {
                name: '父组件内容',
                fontSize: 15,
                msg: ''
            },
            methods: {
                handle() {
                    this.fontSize += 5
                },
                handle1(msg) {
                    console.log(msg)
                    this.msg = msg
                }
            }
        })
    </script>
</body>

</html>